<!DOCTYPE html>
<html lang="en">
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="http://localhost:10000/js/jquery-1.11.3.min.js"></script>
    <script src="http://localhost:10000/js/ruku.js"></script>
</head>
<body>
<h4>入库管理>>入库单查询</h4>
<form action="http://localhost:10000/ruku/selectrukudan.do">
    <table border="1px">
        <tr>
            <td>
                入库时间
            </td>
            <td>
                <input type="date" name="start" th:value="${session.start}"> >/<input type="date" name="end" th:value="${session.end}">
            </td>
        </tr>
        <tr>
            <td>
                入库单号
            </td>
            <td>
                <input type="text" name="billID" id="billID" th:value="${session.billID}">
            </td>
        </tr>
        <tr>
            <td>
                货主名
            </td>
            <td>
                <input type="text" name="custName" id="custName"  th:value="${session.custName}">
            </td>
        </tr>
        <tr>
            <td>

            </td>
            <td>
                <input type="submit" value="查询">
            </td>
        </tr>
    </table>
</form>

<table border="1px" style="margin-top: 15px" id="fenye" th:if="${session.pageInfoo != null}">
<!--    <tr>-->
<!--        <td colspan="9">没有找到记录。<button style="float: right">Clear</button><button  style="float: right">Filter</button></td>-->
<!--    </tr>-->
<!--    <tr>-->
<!--        <td><input type="text"></td>-->
<!--        <td><input type="text"></td>-->
<!--        <td><input type="text"></td>-->
<!--        <td><input type="text"></td>-->
<!--        <td><input type="text"></td>-->
<!--        <td><input type="text"></td>-->
<!--        <td><input type="text"></td>-->
<!--        <td><input type="text"></td>-->
<!--        <td><input type="text"></td>-->
<!--        <td rowspan="2">是否删除</td>-->
<!--    </tr>-->
    <tr>
        <td></td>
        <td>入库单单号</td>
        <td>结算员</td>
        <td>货主</td>
        <td>业务时间</td>
        <td>应收款</td>
        <td>实际收款</td>
        <td>力资源</td>
        <td>其他费用</td>
        <td>入库单状态</td>
    </tr>
    <tr th:each="every:${session.pageInfoo.list}">
        <td>
            <input type="radio" name="radio" onclick="fenyedanxuan(this.value)">
        </td>
        <td th:text="${every.billID}" name="billID1">

        </td>

        <td th:text="${every.get('billTransactor')} == null ? 'null' : ${every.get('billTransactor')}">

        </td>
        <td th:text="${every.custName}" >

        </td>
        <td th:text="${every.billDate}" >

        </td>
        <td  th:text="${every.billPayable}">

        </td>
        <td  th:text="${every.billPaid}">

        </td>
        <td  th:text="${every.billFeeTruckage}" >

        </td>
        <td  th:text="${every.billFeeOther}">

        </td>
        <td  th:text="${every.billState}">

        </td>
    </tr>
<!--    <tr style="text-align: center">-->
<!--        <td colspan="9">没有相关记录！</td>-->
<!--    </tr>-->
</table>



<input type="hidden" id="num" th:value="${session.num1}"/>
<input type="hidden" id="size" th:value="${session.size1}"/>

<tr>
    <button type="button" th:value="${session.pageInfoo.getPageNum()>1?session.pageInfoo.getPageNum()-1:session.pageInfoo.getPageNum()}"
            onclick="lastpage(this.value)">上一页
    </button>

    <select name="pageSize" id="pageSize" onchange="getpage(this.value)">
        <option value="5" th:selected="${session.size1 == 5}">5</option>
        <option value="10" th:selected="${session.size1 == 10}">10</option>
        <option value="15" th:selected="${session.size1 == 15}">15</option>
    </select>

    <button type="button" th:value="${session.pageInfoo.getPageNum()<session.pageInfoo.getPages()?session.pageInfoo.getPageNum()+1:session.pageInfoo.getPageNum()}"
            onclick="lastpage(this.value)">下一页
    </button>

    <!--    <button th:value="${session.pageInfo.getPageNum()<session.pageInfo.getSize()?session.pageInfo.getPageNum()+1:session.pageInfo.getPageNum()}"-->
    <!--            onclick="lastpage(this.value)">下一页-->
    <!--    </button>-->
</tr>
<br><br><br>
<form>
    <table width="500px" border="1px" id="rukudanMess">
        <!--        <tr>-->
        <!--            <td>入库单号</td>-->
        <!--            <td><input type="text" th:value="${session.wmsTBill.billID} == null ? 'null' : ${session.wmsTBill.billID}"></td>-->
        <!--        </tr>-->
        <!--        <tr>-->
        <!--            <td>货主</td>-->
        <!--            <td><input type="text" th:value="${session.wmsTBill.wmsTCustomer.custName}"></td>-->
        <!--        </tr>-->
        <!--        <tr>-->
        <!--            <td>力资费</td>-->
        <!--            <td><input type="text" th:value="${session.wmsTBill.billFeeTruckage}"></td>-->
        <!--        </tr>-->
        <!--        <tr>-->
        <!--            <td>业务时间</td>-->
        <!--            <td><input type="text" th:value="${session.wmsTBill.billDate}"></td>-->
        <!--        </tr>-->
        <!--        <tr>-->
        <!--            <td>最后编辑时间</td>-->
        <!--            <td><input type="text" th:value="${session.wmsTBill.billEditTime}"></td>-->
        <!--        </tr>-->
        <!--        <tr>-->
        <!--            <td>单据状态</td>-->
        <!--            <td><input type="text" th:value="${session.wmsTBill.billState}"></td>-->
        <!--        </tr>-->
        <!--        <tr>-->
        <!--            <td>备注</td>-->
        <!--            <td><textarea style="resize:none; width: 150px; height: 50px"></textarea></td>-->
        <!--        </tr>-->
        <!--        <tr>-->
        <!--            <td>是否删除</td>-->
        <!--            <td><input type="radio" name="radio1"><input type="radio" name="radio1"></td>-->
        <!--        </tr>-->
        <!--        <tr>-->
        <!--            <td></td>-->
        <!--            <td><input type="submit" value="提交"></td>-->
        <!--        </tr>-->
    </table>
</form>
</body>
<script>
    function getpage(page) {

        var custName = $("#custName").val();
        var billID = $("#billID").val();
        var pageNum = $("#num").val();

        window.alert(custName + '&' + 'billID' + '-' + page + '&' + pageNum);

        window.location = "/ruku/selectrukudan.do?custName=" + custName + "" +
            "&billID=" + billID + "&pageNum=" + pageNum + "&pageSize=" + page;

    }

    function lastpage(page) {
        var custName = $("#custName").val();
        var billID = $("#billID").val();
        var pageSize = $("#pageSize").val();
        window.location = "/ruku/selectrukudan.do?custName=" + custName + "" +
            "&billID=" + billID + "&pageNum=" + page + "&pageSize=" + pageSize;
    }

    function fenyedanxuan() {
        $("#rukudanMess").html("");
        let billID = document.getElementsByName("billID1");
        let radio = document.getElementsByName("radio");
        for( let i=0;i<radio.length;i++){
            if(radio[i].checked==true){
                $.ajax({
                    type:"get",
                    url:"rukudanMess.do",
                    data:"billID="+billID[i].innerHTML,
                    success:function (data) {
                    $("#rukudanMess").append("  <tr>\n" +
                        "            <td>入库单号</td>\n" +
                        "            <td><input type=\"text\" id=\"billID2\" value='"+data.billID+"'></td>\n" +
                        "        </tr>\n" +
                        "        <tr>\n" +
                        "            <td>货主</td>\n" +
                        "            <td><input type=\"text\" id=\"custName1\" value='"+data.wmsTCustomer.custName+"'></td>\n" +
                        "        </tr>\n" +
                        "        <tr>\n" +
                        "            <td>力资费</td>\n" +
                        "            <td><input type=\"text\" id=\"lizi\" value='"+data.billFeeTruckage+"'></td>\n" +
                        "        </tr>\n" +
                        "        <tr>\n" +
                        "            <td>业务时间</td>\n" +
                        "            <td><input type=\"date\" id=\"time\" value='"+data.billDate+"'></td>\n" +
                        "        </tr>\n" +
                        "        <tr>\n" +
                        "            <td>最后编辑时间</td>\n" +
                        "            <td><input type=\"date\"  value='"+data.billEditTime+"'></td>\n" +
                        "        </tr>\n" +
                        "        <tr>\n" +
                        "            <td>单据状态</td>\n" +
                        "            <td><input type=\"text\" value='"+data.billState+"'></td>\n" +
                        "        </tr>\n" +
                        "        <tr>\n" +
                        "            <td>备注</td>\n" +
                        "            <td><textarea style=\"resize:none; width: 150px; height: 50px\"></textarea></td>\n" +
                        "        </tr>\n" +
                        "        <tr>\n" +
                        "            <td>是否删除</td>\n" +
                        "            <td><input type=\"radio\" name=\"radio1\" id='delete' onclick='deleteMess(this.value)'>删除<input type=\"radio\" name=\"radio1\" id='huodong' onclick='updateMess(this.value)'>活动</td>\n" +
                        "        </tr>")

                    }
                })
            }

        }


        // let billID = document.getElementsByName("billID1");
        // // let custName = document.getElementsByName("custName1");
        // let radio = document.getElementsByName("radio");
        // for( let i=0;i<radio.length;i++){
        //     if(radio[i].checked==true){
        //         window.location="http://localhost:10000/ruku/rukudanMess.do?billID="+billID[i].innerHTML;
        //     }else{
        //         $("#rukudanMess").html("")
        //     }
        // }

    }
    //删除入库单
    function deleteMess() {
        if(window.confirm('是否要删除该条信息？')){
            alert("删除成功！")
            let billID=document.getElementsByName("billID1");;
            let radio = document.getElementsByName("radio");
            for( let i=0;i<radio.length;i++){
                if(radio[i].checked==true){
                    window.location = "deleteMess.do?billID="+billID[i].innerHTML;
                }

            }

        }else{
            //alert("取消");
            return false;
        }
    }
    //更新入库单
    function updateMess() {
        if(window.confirm('是否要更新该条信息？')){
            alert("更新成功！")
            let billID=document.getElementById("billID2").value;;
            let custName1 = document.getElementById("custName1").value;
            let lizi = document.getElementById("lizi").value;
            let time = document.getElementById("time").value;
            window.location = "updateMess.do?billID=" + billID + "&custName=" + custName1 + "&billDate=" + time + "&billEditTime=" + time + "&billFeeTruckage=" + lizi;
        }else{
            //alert("取消");
            return false;
        }
    }
</script>
</html>